package org.jeecg.modules.geek.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.geek.entity.DbResource;
import org.jeecg.modules.geek.mapper.DbResourceMapper;
import org.jeecg.modules.geek.service.IDbResourceService;
import org.springframework.stereotype.Service;

/**
 * @Description: 资源表
 * @Author: jeecg-boot
 * @Date:   2025-08-26
 * @Version: V1.0
 */
@Service
public class DbResourceServiceImpl extends ServiceImpl<DbResourceMapper, DbResource> implements IDbResourceService {

    @Override
    public void clickCount(String id) {
        DbResource dbResource = baseMapper.selectById(id);
        Integer newClickCount;
        Object clickNumberObj = dbResource.getClickNumber();
        if (clickNumberObj == null) {
            newClickCount = 1;
        } else {
            newClickCount = Integer.valueOf(clickNumberObj.toString()) + 1;
        }
        dbResource.setClickCount(newClickCount);
        dbResource.setClickNumber(String.valueOf(newClickCount));
        baseMapper.updateById(dbResource);
    }
}
